<?php
	require ('common.inc.php');
	$sql="select * from ld_regconfig where field_name='rgmbq'";
	$db->query($sql,2);
	$rgmbq = $db->rs;
	$rmbq=explode('|',$rgmbq['field_option']);
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" name="viewport">
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />
    <script type="text/javascript" src="public/home/js/jquery.min.js"></script>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="public/home/js/html5.js"></script>
    <![endif]-->
    <script type="text/javascript" src="public/home/js/jquery.cycle.all.min.js"></script>
    <link href="public/home/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="public/home/css/H-ui.reset.css" rel="stylesheet" type="text/css" />
    <link href="public/home/css/style.css" rel="stylesheet" type="text/css" /><!--自己的样式-->
    <link href="public/home/css/plugs.css" rel="stylesheet" type="text/css" /><!--自己的样式-->

    <script type="text/javascript" src="public/home/js/jquery.SuperSlide.js"></script>
</head>
<style>
    .title_login{font-size: 16px;font-weight: normal;text-align: center;margin-bottom: 18px;color:#6a6c6f;}
    .form-horizontal .form-group{margin-left:0;margin-right: 0;}
    .form-control{-webkit-box-shadow: none;box-shadow: none;border:none;border-bottom: 1px solid #eee;height: 40px;color:#55595c;}
</style>
<body class="bg-df" style="position: relative;">
<!-- <div class="header">
    <div class="top-box">
        <div class="w-d top-img">

        </div>
    </div>
    <div class="w-d cl">
        <label class="lab-img"></label>
        <div class="zc-banner f-r mt-30">
            <img alt="" src="public/home/images/zc-banner.png">
        </div>
    </div>

</div> -->
<div class="zhuce-box">
    <div class="w-d">
        <p class="ftpasstop">
                <img src="public/home/images/sas-logo1.png">
            </p>
        <div class="zhuce mt-45" style="width:90%;max-width: 320px;padding:24px;">
            <!-- <div class="row-title">
                <p class="tip-title">修改交易密码</p>
            </div> -->

            <!-- <h2>修改交易密码</h2> -->
            <form method="post" name="theform" action="chkeditpwd.php" onsubmit="return doLogin()" class="form-horizontal">
                <input type="hidden" name="action" value="tradepwd">
                <div class="zhuce-from mt-10 changedealpwd">
                <h3 class="title_login">修改交易密码</h3>
					<!-- <div class="item">
						<div class="left-item f-l">
							<span class="title">请选择密保问题：</span>
						 </div>
						 <div class="right-item f-l">
							<select  name="mbq" id="mbq" class="reginput" required="required">
								<?php foreach ($rmbq as $kk => $vv) {
								?>
								<option value="<?php echo $kk?>"><?php echo $vv?></option>
								<?php
								}?>
							</select>
						</div>
					</div> -->
                    <!-- <div class="form-group">
                        <label class="col-md-3 control-label ui-sortable">密保问题</label>
                        <div class="col-md-9 ui-sortable">
                            <select  name="mbq" id="mbq" class="form-control" required="required">
                                <?php foreach ($rmbq as $kk => $vv) {
                                ?>
                                <option value="<?php echo $kk?>"><?php echo $vv?></option>
                                <?php
                                }?>
                            </select>
                        </div>
                    </div> -->

					<!-- <div class="item">
						 <div class="left-item f-l">
							<span class="title">密保答案：</span>
						 </div>
						 <div class="right-item f-l">
							<input type="text" class="input-text reginput" id="rgmba" name="rgmba" required="required" value="密保答案" onblur="if(this.value == '')this.value='密保答案';" onclick="if(this.value == '密保答案')this.value='';"/>
						</div>
					</div> -->
                   <!--  <div class="form-group">
                        <label class="col-md-3 control-label ui-sortable">密保答案</label>
                        <div class="col-md-9 ui-sortable">
                            <input type="text" class="form-control" id="rgmba" name="rgmba" required="required" value="密保答案" onblur="if(this.value == '')this.value='密保答案';" onclick="if(this.value == '密保答案')this.value='';"/>
                        </div>
                    </div> -->
                    <!-- <div class="item">
                        <div class="left-item f-l">
                            <span class="title">手机号码：</span>
                        </div>
                        <div class="right-item f-l">
                            <input type="text" class="input-text" id="rgphone" name="rgmobile" required="required" id="phone" value="手机号码" onblur="if(this.value == '')this.value='手机号码';" onclick="if(this.value == '手机号码')this.value='';"/>
                        </div>
                    </div> -->
                    <div class="form-group">
                        <div class="ui-sortable">
                            <input type="text" class="form-control" id="rgphone" name="rgmobile" required="required" id="phone" placeholder="手机号码"/>
                        </div>
                    </div>
                    <!-- <div class="item">
                        <div class="left-item f-l">
                            <span class="title">手机验证码：</span>
                        </div>
                        <div class="right-item f-l">
                            <input type="text" id="code" class="input-text" name="pcode" required="required" style="width: 250px;"/>
                            <input type="button" value="发送验证码" id="btnSendCode" onclick="sendSms()" style="display: inline-block;color:#fff;cursor:pointer;font-size:16px;width:125px;height: 48px;background:#3c9cf6;border-radius:5px;border: 0;margin-left: 17px;"/>

                        </div>
                    </div> -->
                    <div class="form-group">
                        <div class="ui-sortable">
                            <div class="row">
                                <div class="col-md-7 col-xs-7" style="margin-top: 5px;">
                                    <input type="text" id="code" class="form-control" name="pcode" required="required"placeholder="验证码" />
                                </div>
                                <div class="col-md-5 col-xs-5" style="margin-top: 5px;padding-left:4px;padding-right:4px;">
                                    <input type="button" value="发送验证码" id="btnSendCode" onclick="sendSms()" class="btn"  style="background-color: #3f51b5;color:#fff;line-height: 28px;width:106px;"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group" style="margin-top: 32px;">
                        <div class="ui-sortable">
                             <input type="submit" class="denglubut" value="提交修改" onclick="document.theform.onsubmit();" style="width: 100%;" />
                        </div>
                    </div>
                    <!-- <div class="item mt-20">
                        <div class="left-item f-l">
                            <span class="title"></span>
                        </div>
                        <div class="right-item f-l">
                            <input type="submit" class="input-btn" value="提交修改" onclick="document.theform.onsubmit();"/>
                        </div>
                    </div> -->
                </div>
            </form>
        </div>

    </div>
</div>
<script type="text/javascript" src="public/home/js/layer/layer.js"></script>
<script type="text/javascript">
    layer.config({
    	skin:'layer-ext-moon',
    	extend:'skin/moon/style.css'
    });
    /**/
    function doLogin() {
        //检测手机
		var phone = $.trim($("#rgphone").val());
		var result = phone.match(/^1(([3][456789])|([5][012789])|([8][12378]))[0-9]{8}$/);
		result = result || phone.match(/^1(([3][012])|([5][56])|([8][56]))[0-9]{8}$/);
		result = result || phone.match(/^1(([3][3])|([5][3])|([8][09]))[0-9]{8}$/);
		if(phone==""){
			alert("请输入手机号码！");
			return false;
		}

		if (result == null) {
			alert("手机号码格式不正确");
			return false;
		}else {
			sw=false;
		  $.ajax({
			type: "get",
			dataType: "json",
			url: "/ajax.php?act=chkmobile2&mobile="+phone,
			success: function(data){
				if(data.tips!='手机号码检测通过'){ //表示手机号不存在，不可以修改密码
					alert("您输入的手机号码未注册！");
					sw=true;
				}
			},
			error: function(){

			},
			cache: false,
			async: false
		  });
		  if(sw){
             return false;
		  }
		}
        //检测验证码是否为空
        var code=$("#code").val();
        if(code.length==0){
            layer.alert('验证码不能为空');
            return false;
        }
		var yanzhengma = /^\d{6}$/;
		if(!yanzhengma.test(code)){
			alert("验证码错误！");
			return false;
		}
		return true;
    }

    var InterValObj; //timer变量，控制时间
    var count = 60; //间隔函数，1秒执行
    var curCount;//当前剩余秒数
    function sendSms(){
        $.ajaxSetup({
            async: false
        });

        //检测手机格式
		var phone = $.trim($("#rgphone").val());
		var result = phone.match(/^1(([3][456789])|([5][012789])|([8][12378]))[0-9]{8}$/);
		result = result || phone.match(/^1(([3][012])|([5][56])|([8][56]))[0-9]{8}$/);
		result = result || phone.match(/^1(([3][3])|([5][3])|([8][09]))[0-9]{8}$/);
		if(phone==""){
			alert("请输入手机号码！");
			return false;
		}

		if (result == null) {
			alert("手机号码格式不正确");
			return false;
		}else {
			sw=false;
		  $.ajax({
			type: "get",
			dataType: "json",
			url: "/ajax.php?act=chkmobile2&mobile="+phone,
			success: function(data){
				if(data.tips!='手机号码检测通过'){ //表示手机号不存在，不可以修改密码
					alert("您输入的手机号码未注册！");
					sw=true;
				}
			},
			error: function(){

			},
			cache: false,
			async: false
		  });
		  if(sw){
             return false;
		  }
		}

    	 curCount = count;
  	　　//设置button效果，开始计时
  	     $("#btnSendCode").attr("disabled", "true");
  	     $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
  	     InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次

    	 $.ajax({
			type: "get",
			dataType: "json",
			url: "/plus/sendsms.php?phone="+phone,
			success: function(data){
				layer.alert(data.res);
			},
			error: function(){

			},
			cache: false,
			async: false
		 });
    }
    //timer处理函数
    function SetRemainTime() {
      if(curCount == 0){
          window.clearInterval(InterValObj);//停止计时器
          $("#btnSendCode").removeAttr("disabled");//启用按钮
          $("#btnSendCode").val("重新发送验证码");
       }else{
           curCount--;
           $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
      }
    }
</script>
<!-- <div class="bottom" style="color: #333;margin-top: 30px;">Copyright ©2016 凯莎国际 版权所有</div> -->
</body>
</html>
